/**
 * 
 */
package com.huawei.esdk.uc.sametime.models;

import org.eclipse.swt.graphics.Image;

import com.huawei.esdk.uc.jna.Constants.AccountType;
import com.huawei.esdk.uc.jna.Constants.MemStatusInCall;
import com.huawei.esdk.uc.sametime.EsdkPluginActivator;
import com.huawei.esdk.uc.sametime.services.UCPresenceService;
import com.huawei.esdk.uc.sametime.util.PluginUtil;
import com.ibm.collaboration.realtime.people.Person;

/**
 * @author y00175154
 * 
 */
public class Participant
{

    private String number;

    private int callNumType = AccountType.UC_ACCOUNT;

    private String contactId;

    private String ucAccount;

    private int statusInConf = MemStatusInCall.CONF_MEM_INVITING;

    public int getUcStatus()
    {
        return UCPresenceService.getCurrentPresence(getUcAccount());
    }

    public Image getStatusImage()
    {
        Person person = getPerson();
        if (null != person)
        {
            return person.getStatusImage();
        }
        return null;
    }

    public String getNickname()
    {
        Person person = getPerson();
        if (null != person)
        {
            return person.getDisplayName();
        }
        return getUcAccount();
    }

    public String getNumber()
    {
        return number;
    }

    public void setNumber(String number)
    {
        this.number = number;
    }

    public int getCallNumType()
    {
        return callNumType;
    }

    public void setCallNumType(int callNumType)
    {
        this.callNumType = callNumType;
    }

    public int getStatusInConf()
    {
        return statusInConf;
    }

    public void setStatusInConf(int statusInConf)
    {
        this.statusInConf = statusInConf;
    }

    /**
     * 
     * @param contactId 传入ContactId
     */
    public void setContactId(String contactId)
    {
        this.contactId = contactId;
    }

    public void setUcAccount(String ucAccount)
    {
        this.ucAccount = ucAccount;
    }

    public Person getPerson()
    {
        if(null == EsdkPluginActivator.getDefault())
        {
            return null;
        }
        return EsdkPluginActivator.getDefault().getPersonMap().get(
                getUcAccount());
    }

    public String getUcAccount()
    {
        if (null == ucAccount)
        {
            return PluginUtil.getUCAccountFromContactID(this.contactId);
        }
        
        return ucAccount;
    }

}
